using System;
using System.Collections.Generic;
using System.Text;

using OOFluidFramework.Operators;

namespace OOFluidFramework.Utility
{
    class Interpolation
    {
        public virtual double ReportWeight(FluidOperator op1, FluidOperator op2);
        public virtual double ReportWeight(double Reference);
    }
    class Poly6Interpolation : Interpolation
    {
        private double d;
        private double kernel;
        private double d2;
        public Poly6Interpolation(double d)
        {
            this.d = d;
            d2 = d * d;
            kernel = 315.0 / (201.0624 * d2 * d2 * d2 * d);
            //201.0624 = 60 * PI
        }
        public override double ReportWeight(FluidOperator op1, FluidOperator op2)
        {
            return ReportWeight(op1.ReportDistanceP2(op2));
        }
        public override double ReportWeight(double DistanceP2)
        {
            double diff = d2 - DistanceP2;
            return kernel * diff * diff * diff;
        }
    }
    class DistanceLinearInterpolation : Interpolation
    {
        public override double ReportWeight(FluidOperator op1, FluidOperator op2)
        {
            return ReportWeight(op1.ReportDistanceP2(op2));
        }
        public override double ReportWeight(double Reference)
        {
            return Math.Sqrt(Reference);
        }
    }
}
